package cn.stylefeng.guns.modular.gridsystem.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.gridsystem.service.WpUploadLogService;
import cn.stylefeng.guns.modular.gridsystem.model.param.WpUploadLogParam;

import javax.annotation.Resource;

/**
 * 倾角上传日志 控制器
 *
 * @author: ssy
 * @date: 2022/02/16 10:59
 */
@RestController
public class WpUploadLogController {

    @Resource
    private WpUploadLogService wpUploadLogService;

    /**
     * 分页查询倾角上传日志
     *
     * @author ssy
     * @date 2022/02/16 10:59
     */
    @GetMapping("/wpUploadLog/page")
    @BusinessLog(title = "倾角上传日志_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(WpUploadLogParam wpUploadLogParam) {
        return new SuccessResponseData(wpUploadLogService.page(wpUploadLogParam));
    }

    /**
     * 获取全部倾角上传日志
     *
     * @author ssy
     * @date 2022/02/16 10:59
     */
    @GetMapping("/wpUploadLog/list")
    @BusinessLog(title = "倾角上传日志_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list( ) {
        return new SuccessResponseData(wpUploadLogService.list());
    }

    /**
     * 获取最新倾角
     * @param wpUploadLogParam
     * @return
     */
    @GetMapping("/wpUploadLog/getNewOne")
    public ResponseData getOne(WpUploadLogParam wpUploadLogParam) {
        return new SuccessResponseData(wpUploadLogService.getNewOne(wpUploadLogParam));
    }

    /**
     * 查看详情倾角上传日志
     *
     * @author ssy
     * @date 2022/02/16 10:59
     */
    @GetMapping("/wpUploadLog/detail")
    @BusinessLog(title = "倾角上传日志_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(WpUploadLogParam.detail.class) WpUploadLogParam wpUploadLogParam) {
        return new SuccessResponseData(wpUploadLogService.detail(wpUploadLogParam));
    }

    /**
     * 添加倾角上传日志
     *
     * @author ssy
     * @date 2022/02/16 10:59
     */
    @PostMapping("/wpUploadLog/add")
    @BusinessLog(title = "倾角上传日志_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(WpUploadLogParam.add.class) WpUploadLogParam wpUploadLogParam) {
        wpUploadLogService.add(wpUploadLogParam);
        return new SuccessResponseData();
    }

    /**
     * 删除倾角上传日志
     *
     * @author ssy
     * @date 2022/02/16 10:59
     */
    @PostMapping("/wpUploadLog/delete")
    @BusinessLog(title = "倾角上传日志_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(WpUploadLogParam.delete.class) WpUploadLogParam wpUploadLogParam) {
        wpUploadLogService.delete(wpUploadLogParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑倾角上传日志
     *
     * @author ssy
     * @date 2022/02/16 10:59
     */
    @PostMapping("/wpUploadLog/edit")
    @BusinessLog(title = "倾角上传日志_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(WpUploadLogParam.edit.class) WpUploadLogParam wpUploadLogParam) {
        wpUploadLogService.edit(wpUploadLogParam);
        return new SuccessResponseData();
    }


}
